package com.itheima.day14.day14work4;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

public class Test {
    public static void main(String[] args) {
        //创建默认线程池
        ExecutorService executorService = Executors.newCachedThreadPool();
         executorService.submit(()-> System.out.println("我执行了"));
         //创建有上限的线程池
        ExecutorService executorService1 = Executors.newFixedThreadPool(10);
        executorService1.submit(()-> System.out.println("我第二次执行了"));
        executorService.shutdown();
        executorService1.shutdown();
        //volatile 只能保证线程的每次读到的数据是最新值，不能保证原子性
       /* //线程执行关于数据操作的三步
        //从共享数据种读取数据到本线程的栈种，
        //修改本线程栈种副本的值
        //在将修改的值赋值给共享数据 */

    }
}
